#pragma once

#include "NFComm/NFPluginModule/NFIRankHandleModule.h"

class NFIRankModule;
class NFINetModule;
class NFIOfflineModule;
class NFITimerModule;
class NFILogModule;

#define START_TIMER_SET_RANK_DATA ("set_rank_data")
#define TIME_SET_RANK_DATA (6)

#define START_TIMER_LOAD_RANK_DATA ("load_rank_data")
#define TIME_LOAD_RANK_DATA (300)

class NFCRankHandleModule : public NFIRankHandleModule
{
public:
    NFCRankHandleModule(NFIPluginManager* p)
    {
        pPluginManager = p;
    }

    virtual bool Init();
    virtual bool AfterInit();
    virtual bool Execute();
    virtual bool BeforeShut();
    virtual bool Shut();
    virtual bool Finalize();
public:
    virtual void    StartTimerSetRankData();
    virtual int     SetRankDataProcess(const std::string& nTimerName, const uint64_t nInterVal, const uint32_t nCallCount);
public:
    virtual void    StartTimerLoadRankData();
    virtual int     LoadRankDataProcess(const std::string& nTimerName, const uint64_t nInterVal, const uint32_t nCallCount);
public:
    virtual NFIRankModule::RankValue GetIndex(const NFGUID& self, const NFIRankModule::RANK_TYPE type);
    virtual void RangeByIndexReturnFunc(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
public:
    virtual void OnGetRankingListProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen);
protected:
    NFIRankModule* m_pRankModule = nullptr;
    NFINetModule* m_pNetModule = nullptr;
    NFIOfflineModule* m_pOfflineModule = nullptr;
    NFITimerModule* m_pTimerModule = nullptr;
    NFILogModule* m_pLogModule = nullptr;
private:
    std::map<NFIRankModule::RANK_TYPE, std::vector<NFIRankModule::RankValue>>   mRankValueMap;
};